<?php
// The source code packaged with this file is Free Software, Copyright (C) 2005 by
// Ricardo Galli <gallir at uib dot es>.
// It's licensed under the AFFERO GENERAL PUBLIC LICENSE unless stated otherwise.
// You can get copies of the licenses here:
// 		http://www.affero.org/oagpl.html
// AFFERO GENERAL PUBLIC LICENSE is also included in the file called "COPYING".
if($_POST['xmlhttp']){
	include_once('Smarty.class.php');
	$main_smarty = new Smarty;
	
	include('config.php');
	include(mnminclude.'html1.php');
	include(mnminclude.'ts.php');
	include(mnminclude.'link.php');
	include_once(mnminclude.'comment.php');
	include_once(mnminclude.'hunt.php');
	include(mnminclude.'tags.php');
	include(mnminclude.'smartyvariables.php');
	
	$linkid = strip_tags($_POST['linkid']);
	
	$newtags = $_POST['newtags'];
	$linkres = new Link();
	$linkres->id = strip_tags($_POST['linkid']);
	$linkres->read();
	if($linkres->title != strip_tags(trim($_POST['newtitle']))){
		$linkres->title = strip_tags(trim($_POST['newtitle']));
		$linkres->title_url = makeUrlFriendly($linkres->title);
	}
	$linkres->content = strip_tags(trim($_POST['newdesc']), Story_Content_Tags_To_Allow);
	$linkres->content = str_replace("\n", "<br />", $linkres->content);
	$linkres->link_summary = utf8_substr(strip_tags(trim($_POST['newdesc']), Story_Content_Tags_To_Allow), 0, StorySummary_ContentTruncate - 1);
	$linkres->link_summary = str_replace("\n", "<br />", $linkres->link_summary);		
		
	$linkres->tags = tags_normalize_string(strip_tags(str_replace('，',',',trim($_POST['newtags']))));
	tags_insert_string($linkres->id, $dblang, $linkres->tags);
	$linkres->store();
	
	$hunt = new Hunt();
	$hunt->linkid = $linkid;
	$hunt->read();
	$hunt->deadline = unixtimestamp($_POST['newdeadline']);
	//echo $_POST['newdeadline'];
	$hunt->store();
	
	header('Content-Type: text/plain; charset=UTF-8');
	echo ('success:');
	die();
}

?>
